﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ZeldoEngineObjects.Database
{
    public class SqlChipset
    {
        public static List<Chipset> LireChipset()
        {
            using (var entities = new defaultEntities())
            {
                return entities.Chipset.ToList();
            }
        }

        public static void EffacerChipset(Chipset chipset)
        {
            using (var entities = new defaultEntities())
            {
                var chip = entities.Chipset.Where(c => c.ChipsetId == chipset.ChipsetId).First();

                if (chip != null)
                {
                    entities.Chipset.DeleteObject(chip);
                    entities.SaveChanges();
                }
            }
        }

        public static void EnregistrerChipset(Chipset chipset)
        {
            using (var entities = new defaultEntities())
            {
                entities.Chipset.AddObject(chipset);
                entities.SaveChanges();
            }
        }
    }
}
 